package com.cn.sl.server.api.system.user.model.dto

import com.cn.sl.server.util.PHONE_PATTERN
import io.swagger.v3.oas.annotations.media.Schema
import jakarta.validation.constraints.NotBlank
import jakarta.validation.constraints.Pattern

open class PhoneCheckParam(
    open val id: Long?,
    @field:NotBlank(message = "手机号不能为空")
    @field:Pattern(regexp = PHONE_PATTERN, message = "手机号格式不正确")
    @field:Schema(description = "手机号")
    open var phone: String?,
) {

}

data class UserPhoneExistParam(
    override val id: Long?,
    override var phone: String?,
) : PhoneCheckParam(id, phone) {
    fun toDto(): UserPhoneExistDto {
        return UserPhoneExistDto(phone!!, id)
    }
}

@Schema(description = "用户手机号是否存在")
data class UserPhoneExistDto(
    @field:Schema(description = "手机号")
    val phone: String,
    @field:Schema(description = "用户id")
    val id: Long?
)
